package demofactory;

public class ProxyUser {
    private User realuser;
    public ProxyUser(User user){
        this.realuser = user;
    }
    public void menu(){
        this.realuser.menu();
    }
    public void borrowBook(String bookName){
        System.out.println("检查权限");
        if(realuser instanceof NormalUser){
            ((NormalUser)this.realuser).borrowBook(bookName);
        }else{
            System.out.println("没有权限");
        }
    }
    public void addBook(String bookName){
        System.out.println("检查权限");
        if(realuser instanceof AdimalUser){
            ((AdimalUser)this.realuser).addBook(bookName);
        }else{
            System.out.println("没有权限");
        }
    }
}
